package com.bxait.toymail.coupon.config;

import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.bxait.com.constant.ToyMailConstant;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @author Chen
 * @description: myBatis相关配置类
 * @ClassName MyBatisConfig
 * @create 2023-03-14 22:01
 * @Version 1.0
 */
@Configuration
@MapperScan("com/bxait/toymail/coupon/dao")
@EnableTransactionManagement //开启事务
public class MyBatisConfig {

    @Bean
    public PaginationInterceptor paginationInterceptor(){
        PaginationInterceptor interceptor = new PaginationInterceptor();
        // 1.配置请求的页面大于最大页后操作,ture返回首页,false 继续请求
        interceptor.setOverflow(true);
        // 2.设置mybatis最大单页限制数量,默认500条
        interceptor.setLimit(ToyMailConstant.MAX_PAGE_NUMBER);
        return interceptor;
    }
}
